Repository navigation
Conversation
…struct parameters and [UnscopedRef] parameters in mocks Three member shapes made the generated mock fail to compile, and with it the whole test project. - Indexer keys declared `in` or `ref readonly` (also `scoped`) lost their modifier, so the mock did not implement or override the indexer (CS0535, CS9048). The declaration now repeats the modifiers and the wrapped or base indexer gets a `ref readonly` key with `in` (CS9192). A `ref readonly` key outside the ref struct pipeline is set up and verified like an `in` key, because the indexer setups have no slot for a by-reference matcher. - A member with a custom ref struct parameter that returns `Span<T>` or `ReadOnlySpan<T>` by value used the span as a type argument of its ref struct setup (CS9244). These setups now wrap the span like every other span return, for methods and for indexers keyed by a ref struct. - A member whose result may refer to an `[UnscopedRef]` parameter, such as `Span<int> Get([UnscopedRef] ref int value)`, could not return the result of the wrapped or base member (CS9077, CS8347). The method declarations and the `Invoke` method of delegate mocks now repeat the attribute. A plain `ref int` return already compiled.
|
Test Results 69 files 69 suites 49m 50s ⏱️ Results for commit 83e200b. |
🚀 Benchmark ResultsCompared to Memory
Time
CompleteWorkflowBenchmarks
BenchmarkDotNet v0.15.8, Linux Ubuntu 26.04.1 LTS (Resolute Raccoon) AMD EPYC 9V45 4.22GHz, 1 CPU, 4 logical and 2 physical cores .NET SDK 11.0.100 [Host] : .NET 11.0.0 (11.0.0, 11.0.26.53018), X64 RyuJIT x86-64-v4 Job=InProcess Toolchain=InProcessEmitToolchain IterationCount=15 LaunchCount=1 WarmupCount=10 MockCreationBenchmarks
BenchmarkDotNet v0.15.8, Linux Ubuntu 26.04.1 LTS (Resolute Raccoon) AMD EPYC 9V45 4.22GHz, 1 CPU, 4 logical and 2 physical cores .NET SDK 11.0.100 [Host] : .NET 11.0.0 (11.0.0, 11.0.26.53018), X64 RyuJIT x86-64-v4 Job=InProcess Toolchain=InProcessEmitToolchain IterationCount=15 LaunchCount=1 WarmupCount=10 CompleteUnconfiguredBenchmarks
BenchmarkDotNet v0.15.8, Linux Ubuntu 26.04.1 LTS (Resolute Raccoon) Intel Xeon Platinum 8370C CPU 2.80GHz (Max: 3.39GHz), 1 CPU, 4 logical and 2 physical cores .NET SDK 11.0.100 [Host] : .NET 11.0.0 (11.0.0, 11.0.26.53018), X64 RyuJIT x86-64-v4 Job=InProcess Toolchain=InProcessEmitToolchain IterationCount=15 LaunchCount=1 WarmupCount=10 CompleteMethodBenchmarks
BenchmarkDotNet v0.15.8, Linux Ubuntu 26.04.1 LTS (Resolute Raccoon) AMD EPYC 7763 3.01GHz, 1 CPU, 4 logical and 2 physical cores .NET SDK 11.0.100 [Host] : .NET 11.0.0 (11.0.0, 11.0.26.53018), X64 RyuJIT x86-64-v3 Job=InProcess Toolchain=InProcessEmitToolchain IterationCount=15 LaunchCount=1 WarmupCount=10 CompletePropertyBenchmarks
BenchmarkDotNet v0.15.8, Linux Ubuntu 26.04.1 LTS (Resolute Raccoon) INTEL XEON PLATINUM 8573C 3.00GHz, 1 CPU, 4 logical and 2 physical cores .NET SDK 11.0.100 [Host] : .NET 11.0.0 (11.0.0, 11.0.26.53018), X64 RyuJIT x86-64-v4 Job=InProcess Toolchain=InProcessEmitToolchain IterationCount=15 LaunchCount=1 WarmupCount=10 CompleteIndexerBenchmarks
BenchmarkDotNet v0.15.8, Linux Ubuntu 26.04.1 LTS (Resolute Raccoon) AMD EPYC 9V45 4.21GHz, 1 CPU, 4 logical and 2 physical cores .NET SDK 11.0.100 [Host] : .NET 11.0.0 (11.0.0, 11.0.26.53018), X64 RyuJIT x86-64-v4 Job=InProcess Toolchain=InProcessEmitToolchain IterationCount=15 LaunchCount=1 WarmupCount=10 CompleteEventBenchmarks
BenchmarkDotNet v0.15.8, Linux Ubuntu 26.04.1 LTS (Resolute Raccoon) AMD EPYC 9V74 3.69GHz, 1 CPU, 4 logical and 2 physical cores .NET SDK 11.0.100 [Host] : .NET 11.0.0 (11.0.0, 11.0.26.53018), X64 RyuJIT x86-64-v4 Job=InProcess Toolchain=InProcessEmitToolchain IterationCount=15 LaunchCount=1 WarmupCount=10 CallbackBenchmarks
BenchmarkDotNet v0.15.8, Linux Ubuntu 26.04.1 LTS (Resolute Raccoon) AMD EPYC 9V74 3.69GHz, 1 CPU, 4 logical and 2 physical cores .NET SDK 11.0.100 [Host] : .NET 11.0.0 (11.0.0, 11.0.26.53018), X64 RyuJIT x86-64-v4 Job=InProcess Toolchain=InProcessEmitToolchain IterationCount=15 LaunchCount=1 WarmupCount=10 AsyncBenchmarks
BenchmarkDotNet v0.15.8, Linux Ubuntu 26.04.1 LTS (Resolute Raccoon) Intel Xeon 6975P-C 2.70GHz, 1 CPU, 4 logical and 2 physical cores .NET SDK 11.0.100 [Host] : .NET 11.0.0 (11.0.0, 11.0.26.53018), X64 RyuJIT x86-64-v4 Job=InProcess Toolchain=InProcessEmitToolchain IterationCount=15 LaunchCount=1 WarmupCount=10 SequenceBenchmarks
BenchmarkDotNet v0.15.8, Linux Ubuntu 26.04.1 LTS (Resolute Raccoon) Intel Xeon 6975P-C 3.78GHz, 1 CPU, 4 logical and 2 physical cores .NET SDK 11.0.100 [Host] : .NET 11.0.0 (11.0.0, 11.0.26.53018), X64 RyuJIT x86-64-v4 Job=InProcess Toolchain=InProcessEmitToolchain IterationCount=15 LaunchCount=1 WarmupCount=10 |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



The review of #1256 found three member shapes that made the generated mock fail to compile, and with it the whole test project. They are unrelated in code, so each is described on its own.
1. Indexer keys declared
inorref readonlyint this[in int key] { get; },int this[ref readonly int key] { get; }andint this[scoped in int key] { get; }lost their modifier, so the mock did not implement or override the indexer (CS0535, CS9048).[UnscopedRef]andscoped), and aref readonlykey is passed to the wrapped or base indexer within(CS9192).ref readonlykey outside the ref struct pipeline is set up and verified like aninkey (a value or anIParameter<T>matcher), because the indexer setups have no slot for a by-reference matcher.MethodParameter.AsIndexerKey()does this and records the declared modifier inIsRefReadOnlyIndexerKey. Ref struct keys (ref readonly Packet) keep the ref struct pipeline and only needed the modifier.ref readonlymethod parameters.2. Span returns of members with a ref struct parameter
Span<int> Get(Packet packet)(alsoReadOnlySpan<T>, withscopedand at any arity) used the span as a type argument ofRefStructReturnMethodSetup(CS9244). The ref struct setups now wrap the span inSpanWrapper<T>/ReadOnlySpanWrapper<T>like every other span return. The same applied to indexers keyed by a ref struct with a span value (Span<int> this[Packet key]), which are fixed as well.3.
[UnscopedRef]parametersA member whose result may refer to an
[UnscopedRef]parameter, such asSpan<int> Get([UnscopedRef] ref int value), could not return the result of the wrapped or base member (CS9077, CS8347). The method declarations and theInvokemethod of delegate mocks now repeat the attribute. The originally reportedref int Get([UnscopedRef] ref int value)already compiled, because the mock copies the returned value into its own storage; it now repeats the attribute too.Tests
SpecialCases/IndexerKeyRefKindTests,RefStructSpanReturnTests,UnscopedRefParameterTests; two expectations inScopedParameterTestsnow include the attribute.invsref readonlykey, with and without[UnscopedRef]).GeneratorCoverageshapesIndexerKeyRefKinds,RefStructSpanReturns(.NET 10+) andUnscopedRefParameters(.NET 8+) with runtime tests inGeneratorShapes.Open points
[UnscopedRef]that is not public (an internal polyfill, for example from PolySharp on netstandard2.0 or net48) is still not repeated, as before this change, so shape 3 keeps failing for such consumers. Checking accessibility from the compilation would cover it.IsDelegateWithUnsupportedRefStructParameter), also when they return a span.inparameter (int this[int key]andint this[in int key], orRead(int)andRead(in int)) gets two identical setup and verify members (CS0111, CS8646). A combination viaImplementing<T>()compiles.MockGenerationSnapshotTests, likeScopedParameters.csfrom fix: repeat the scoped modifier of parameters in generated mocks #1256.